// use ArrayList to store plates for each pole, instead of using my IntStack

class cplateStack {
  cplateStack() {
    stack = new ArrayList<cplate>();
  }

  void push(cplate plate) {
    stack.add(plate);
  }

  cplate pop() {
    cplate ret = null;
    int size = stack.size();
    if (size > 0) {
      size--;
      ret = stack.get(size);
      stack.remove(size);
    }
    return ret;
  }

  cplate getTop() {
    cplate ret = null;
    int size = stack.size();
    if (size > 0) {
      ret = stack.get(size - 1);
    }
    return ret;
  }

  void clear() {
    stack.clear();
  }

  int size() {
    return stack.size();
  }

  boolean isEmpty() {
    return (stack.size() == 0);
  }

  boolean isNotEmpty() {
    return (stack.size() != 0);
  }

  private ArrayList<cplate> stack;
};
